﻿using System;
using System.Windows.Forms;
using Nyx.Scenes;
using Microsoft.Xna.Framework.Input;

namespace Nyx
{
    /// <summary>
    /// Main form
    /// </summary>
    public partial class NyxForm : Form
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NyxForm"/> class.
        /// </summary>
        public NyxForm()
        {
            InitializeComponent();
            Mouse.WindowHandle = sceneControl1.Handle;
        }

        void NyxForm_Load(object sender, EventArgs e)
        {
            sceneControl1.SetScene(sceneControl1.CreateScene(sceneControl1.Width, sceneControl1.Height));
        }

        void toggleGridButton_Click(object sender, EventArgs e)
        {
            ToolStripItem gridToggle = sender as ToolStripItem;
            if (gridToggle != null)
            {
                sceneControl1.ToggleGrid();
            }
        }

        void zoomInButton_Click(object sender, EventArgs e)
        {
            sceneControl1.Camera.Scale += Camera2D.ScaleStep;
        }

        void zoomResetButton_Click(object sender, EventArgs e)
        {
            sceneControl1.Camera.Scale = Camera2D.DefaultScale;
        }

        void zoomOutButton_Click(object sender, EventArgs e)
        {
            sceneControl1.Camera.Scale -= Camera2D.ScaleStep;
        }

        void zoomInToolStripMenuItem_Click(object sender, EventArgs e)
        {
            zoomInButton.PerformClick();
        }

        void zoomOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            zoomOutButton.PerformClick();
        }

        void zoomResetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            zoomResetButton.PerformClick();
        }

        void toggleGridToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toggleGridButton.PerformClick();
        }

        void resetViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sceneControl1.ResetCamera();
        }
    }
}
